package com.aauedu;

import com.aauedu.springboot.bean.Furn;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@Slf4j
public class HiController {

    //需求：website属性值从application.properties的k-v中获取
    @Value("${my.website}")
    private String website;

    // 转配到HiController
    @Resource
    private Furn furn;

    @RequestMapping("/hi")
    @ResponseBody
    public String hi() {
        System.out.println("my.website:" + website);
        return "hi, springboot!";
    }

    @RequestMapping("/furn")
    @ResponseBody
    public Furn furn() {
//        System.out.println("furn--" + furn);
        //使用slf4j日志输出
        //普通方式
        log.info("furn--" + furn);
        //占位符方式输出
        log.info("furn={} myFurn={}", furn, furn);
        return furn;
    }
}
